﻿/* mvcForum
 * Copyright (C) 2010-2011 Steen F. Tøttrup
 * http://mvcforum.org/
 */

using System;
using System.ComponentModel.DataAnnotations;


namespace mvcForum.Core {

	public class ForumUser {
		public ForumUser() { }
		public ForumUser(String providerId, String name, String emailAddress, String ip) {
			this.ProviderId = providerId;
			this.Name = name;
			this.EmailAddress = emailAddress;
			this.FirstVisit = DateTime.UtcNow;
			this.LastVisit = DateTime.UtcNow;
			this.LastIP = ip;
			this.Deleted = false;
			this.UserFlag = UserFlag.EmailWhenPM;
			this.Active = false;
			this.ExternalAccount = false;
			this.Theme = String.Empty;
		}

		public Int32 Id { get; set; }
		[Required]
		[StringLength(50)]
		public String ProviderId { get; set; }
		[Required]
		[StringLength(Constants.FieldLengths.Username)]
		public String Name { get; set; }
		[Required]
		[StringLength(Constants.FieldLengths.EmailAddress)]
		public String EmailAddress { get; set; }
		[Required]
		public DateTime FirstVisit { get; set; }
		[Required]
		public DateTime LastVisit { get; set; }
		[StringLength(Constants.FieldLengths.IPAddress)]
		public String LastIP { get; set; }
		[Required]
		public Boolean Deleted { get; set; }
		[Required]
		public Boolean Active { get; set; }
		[StringLength(Constants.FieldLengths.TimezoneId)]
		[Required]
		public String Timezone { get; set; }
		[StringLength(Constants.FieldLengths.CultureInfoId)]
		[Required]
		public String Culture { get; set; }
		[StringLength(Constants.FieldLengths.FullName)]
		public String FullName { get; set; }
		public UserFlag UserFlag {
			get {
				return (UserFlag)this.UserFlagValue;
			}
			set {
				this.UserFlagValue = (Int32)value;
			}
		}
		[Required]
		public Int32 UserFlagValue { get; set; }
		[Required]
		public Boolean UseFullName { get; set; }
		[Required]
		public Boolean ExternalAccount { get; set; }
		[StringLength(Constants.FieldLengths.ProviderName)]
		public String ExternalProvider { get; set; }
		[StringLength(Constants.FieldLengths.ProviderId)]
		public String ExternalProviderId { get; set; }
		[StringLength(Constants.FieldLengths.Theme)]
		public String Theme { get; set; }
	}
}